//
//  SpecialEntity.m
//  QQplayground
//
//  Created by zhangxy on 2018/8/7.
//  Copyright © 2018年 zhang. All rights reserved.
//

#import "SpecialEntity.h"

@implementation SpecialEntity


- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    self = [super init];
    if (self) {
        self = [SpecialEntity yy_modelWithDictionary:dictionary];
        
        _list = [[NSMutableArray alloc] init];
        NSArray *imgs = dictionary[@"list"];
        for (NSDictionary *item in imgs) {
            [_list addObject:[[ZZHomeTopicEntity alloc] initWithDictionary:item]];
        }
        
        _author_user_info = [[User alloc] initWithDictionary:dictionary[@"author_user_info"]];
        _nav_name = [self getElementTitle:convertToString(_nav_type)];
    }
    return self;
}


+ (NSDictionary<NSString *,id> *)modelCustomPropertyMapper
{
    return @{
             @"s_id" : @"id",
             @"title":@"title",
             @"intro" : @"intro",
             @"nav_type" : @"nav_type",
             @"author" : @"author",
             @"like_count" : @"like_count",
             @"drop_count" : @"drop_count",
             @"view_count" : @"view_count",
             @"image_url" : @"image_url",
             @"add_time" : @"add_time",
             @"is_like" : @"is_like",
             @"is_drop" : @"is_drop",
             @"share_url" : @"share_url",
             @"intro" : @"intro",
             @"author_url" : @"author_url"
             };
}


-(NSString *) getElementTitle:(NSString *)navType{
    NSArray *aName = [NSArray arrayWithObjects:@"avatar",@"pic",@"sign",@"name",@"group",@"skin",@"show",@"mimi",@"thread",nil];
    
    //比如我们要把@"stormer"作为switch的参数，则取到它在数组中的下标，然后在switch中根据下标来进行处理。
    int index = (int)[aName indexOfObject:navType];
    switch (index){
        case 0:
            return @"头像";
        case 1:
            return @"图片";
        case 2:
            return @"签名";
        case 3:
            return @"网名";
        case 4:
            return @"分组";
        case 5:
            return @"壁纸";
        case 6:
            return @"自拍";
        case 7:
            return @"秘密";
        case 8:
            return @"帖子";
        default:
            return @"图片";
    }
    return @"图片";
}
@end
